'use strict';
app.service('chainBusinessEditService',['$q','utilService',function($q,utilService){
    var _this_=this;

    _this_.query=function($scope){
        var deferred=$q.defer();
        utilService.get({
            url:$scope.app.domain+'chain/info'
        }).then(
            function(res){
                deferred.resolve(res.data);
            },function(e){
                deferred.reject("连接服务器出错");
            }
        );
        return deferred.promise;
    }

    _this_.delImg=function($scope){
        var deferred=$q.defer();
        utilService.api({
            url:$scope.app.domain+"chain/info",
            data:{imgType:$scope.imgType,chainInfoId:$scope.chainInfo.id},
            method:"DELETE"
        }).then(
            function(rlt){
                deferred.resolve(rlt);
            }
        );
        deferred.promise;
    }
    _this_.updateChainInfo=function($scope){
        var deferred=$q.defer();
        utilService.api({
            url:$scope.app.domain+'chain/info/',
            data:$scope.chainInfo,
            method:'PUT'
        }).then(
            function(rlt){
                deferred.resolve(rlt);
            }
        );
        deferred.promise;
    }
}]);